import React, { useState, useCallback } from 'react'

const HooksDemo = () => {
	const [data, setData] = useState({
		name: 'amin',
		age: 17,
	})

	const changeData = useCallback(() => {
		setData((data) => {
			data.name = data.name === 'amin' ? 'zf' : 'amin'
			console.log(data)
			return data
		})
	}, [])
	return (
		<div>
			{`${data.name}:${data.age}`}
			<button onClick={changeData}>按钮</button>
		</div>
	)
}

export default HooksDemo
